/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package DBFunction;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;

import Constant.Constant;

public class fInsertPOI {
	public static void process(String MessageJsonString) throws JSONException {
		JSONObject object = new JSONObject();
		object = (JSONObject) new JSONTokener(MessageJsonString).nextValue();
		
		String phoneNumber = object.getString("currentPhoneNumber");		
		String title = object.getString("title");
		String latitude = object.getString("latitude");
		String longitude = object.getString("longitude");
		String description = object.getString("description");
		String isHidden = object.getString("isHidden");
		String markedTime = Constant.getDateTime();	
		
		String sql = "insert into buddytracking.poi (poi.UserId,poi.Title,poi.Latitude,poi.Longitude,poi.Description,poi.MarkedTime,poi.IsHidden) values((SELECT UserId from buddytracking.user where  user.PhoneNumber=\""+phoneNumber+"\") ,\""+title+"\",\""+latitude+"\",\""+longitude+"\",\""+description+"\",\""+markedTime+"\",\""+isHidden+"\")";
		DB.connectDB.Update(sql);
	}
}
